import request from "@/utils/request.js";

//商品列表
export const goodsListAPI = (obj) => {
  return request({
    method: 'get',
    url: '/goods',
    params: {
      pagenum: obj.pagenum,
      pagesize: obj.pagesize
    }
  })
}

//删除
export const delgoodsAPI = (id) => {
  return request.delete('/goods/' + id)
}

//商品分类
export const goodsortAPI = () => {
  return request.get('/categories')
}

//搜索商品
export const searchGoodsAPI = ({ query, pagenum, pagesize }) => {
  return request.get('/goods', {
    params: {
      query, pagenum, pagesize
    }
  })
}

//添加商品
export const addGoodsAPI = () => {
  return request.post('/goods')
}

//商品参数
export const querygoodsAPI = (id) => {
  return request.get('/categories/{id}/attributes')
}


//获取-商品参数和属性
export const choicequeryAPI = (id, sel) => {
  return request.get(`/categories/${id}/attributes`, {
    params: {
      sel
    }
  })
}

//添加-商品参数和属性
export const addqueryAPI = (id, sel, attr_name) => {
  return request.post(`/categories/${id}/attributes`, {
    attr_sel: sel, attr_name: attr_name
  })
}

//订单列表
export const orderlistAPI = (obj) => {
  return request.get('orders', {
    params: {
      pagenum: obj.pagenum,
      pagesize: obj.pagesize,
    }
  })
}

//查看快递详情
export const kuaidiAPI = (id) => {
  return request.get(`/kuaidi/{id}`)
}

//折线
export const zxAPI = () => {
  return request.get('reports/type/1')
}


//商品分类
export const getCateListAPI = () => {
  return request.get('/categories')
}

//添加商品 获取参数列表
export const addqueryListAPI = (id) => {
  return request.get(`categories/${id}/attributes`, {
    params: {
      sel: "many"
    }
  })
}


//添加商品 获取静态属性列表
export const attrListAPI = (id) => {
  return request.get(`categories/${id}/attributes`, {
    params: {
      sel: "only"
    }
  })
}

//上传图片
export const uploadAPI = (id) => {
  return request.post('/upload')
}